package cn.kgc.controller;

import cn.kgc.form.InterviewAddForm;
import cn.kgc.grace.result.GraceJSONResult;
import cn.kgc.service.InterviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author YC
 */
@RestController
@RequestMapping("/interview")
@Api
@Slf4j
public class InterviewController {

    @Resource
    private InterviewService interviewService;

    @PostMapping("/add")
    @ApiOperation(value = "新增面试邀约")
    public GraceJSONResult addInterview(@RequestBody InterviewAddForm form) {
        return GraceJSONResult.ok(interviewService.addInterview(form));
    }

    @PostMapping("/detail")
    @ApiOperation(value = "面试邀约详情")
    public GraceJSONResult detailInterview(String id) {
        return GraceJSONResult.ok(interviewService.getById(id));
    }

    @PostMapping("/accept")
    @ApiOperation(value = "接受面试邀约")
    public GraceJSONResult acceptInterview(String interviewId, String userId) {
        return GraceJSONResult.ok(interviewService.acceptInterview(interviewId, userId));
    }

    @PostMapping("/refused")
    @ApiOperation(value = " 拒绝面试邀约")
    public GraceJSONResult refusedInterview(String interviewId, String userId) {
        return GraceJSONResult.ok(interviewService.refusedInterview(interviewId, userId));
    }

    @PostMapping("/hrCancel")
    @ApiOperation(value = " HR取消面试邀约")
    public GraceJSONResult hrCancelInterview(String interviewId, String userId) {
        return GraceJSONResult.ok(interviewService.hrCancelInterview(interviewId, userId));
    }

}
